package com.itfreer.data.metadata;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.itfreer.data.metadata.entity.DataMetadataEntity;
import com.itfreer.form.api.BaseRestService;
import com.itfreer.form.api.BaseService;
import com.itfreer.form.api.metadate.MetadataEntity;
import com.itfreer.utils.ResponseEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 元数据
 */
@RestController
@RequestMapping("/metadata")
@Api("默认元数据")
public class RestDefaultMetadataService extends BaseRestService<DataMetadataEntity> {

	@Autowired(required = false)
	private DefaultMetadataService service;
	
	protected DefaultMetadataService getServiceEx() {
		return service;
	}

	@Override
	protected BaseService<DataMetadataEntity> getService() {
		return getServiceEx();
	}

	/**
	 * 根据metadata名称，获取所有元数据
	 * 
	 * @param metaDate
	 * @return
	 */
	@ApiOperation(value = "获取元数据", notes = "根据metadata名称，获取所有元数据")
	@ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "metadata名称", paramType = "path", required = true) })
	@PostMapping(value = "/getEntitys/{id:.+}", produces = "application/json")
	public ResponseEntity<List<MetadataEntity>> getEntitysByID(@PathVariable("id") String metaData) {
		return new ResponseEntity<List<MetadataEntity>>(getServiceEx().getEntitys(metaData));
	}
}
